<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.22">
<title>fok-js使用手册</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
/* Uncomment the following line when using as a custom stylesheet */
/* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
html{font-family:sans-serif;-webkit-text-size-adjust:100%}
a{background:none}
a:focus{outline:thin dotted}
a:active,a:hover{outline:0}
h1{font-size:2em;margin:.67em 0}
b,strong{font-weight:bold}
abbr{font-size:.9em}
abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
dfn{font-style:italic}
hr{height:0}
mark{background:#ff0;color:#000}
code,kbd,pre,samp{font-family:monospace;font-size:1em}
pre{white-space:pre-wrap}
q{quotes:"\201C" "\201D" "\2018" "\2019"}
small{font-size:80%}
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
sup{top:-.5em}
sub{bottom:-.25em}
img{border:0}
svg:not(:root){overflow:hidden}
figure{margin:0}
audio,video{display:inline-block}
audio:not([controls]){display:none;height:0}
fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
legend{border:0;padding:0}
button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
button,input{line-height:normal}
button,select{text-transform:none}
button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
button[disabled],html input[disabled]{cursor:default}
input[type=checkbox],input[type=radio]{padding:0}
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
textarea{overflow:auto;vertical-align:top}
table{border-collapse:collapse;border-spacing:0}
*,::before,::after{box-sizing:border-box}
html,body{font-size:100%}
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
a:hover{cursor:pointer}
img,object,embed{max-width:100%;height:auto}
object,embed{height:100%}
img{-ms-interpolation-mode:bicubic}
.left{float:left!important}
.right{float:right!important}
.text-left{text-align:left!important}
.text-right{text-align:right!important}
.text-center{text-align:center!important}
.text-justify{text-align:justify!important}
.hide{display:none}
img,object,svg{display:inline-block;vertical-align:middle}
textarea{height:auto;min-height:50px}
select{width:100%}
.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
a{color:#2156a5;text-decoration:underline;line-height:inherit}
a:hover,a:focus{color:#1d4b8f}
a img{border:0}
p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
p aside{font-size:.875em;line-height:1.35;font-style:italic}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
h1{font-size:2.125em}
h2{font-size:1.6875em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
h4,h5{font-size:1.125em}
h6{font-size:1em}
hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
em,i{font-style:italic;line-height:inherit}
strong,b{font-weight:bold;line-height:inherit}
small{font-size:60%;line-height:inherit}
code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
ul,ol{margin-left:1.5em}
ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
ul.circle{list-style-type:circle}
ul.disc{list-style-type:disc}
ul.square{list-style-type:square}
ul.circle ul:not([class]),ul.disc ul:not([class]),ul.square ul:not([class]){list-style:inherit}
ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
dl dt{margin-bottom:.3125em;font-weight:bold}
dl dd{margin-bottom:1.25em}
blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
h1{font-size:2.75em}
h2{font-size:2.3125em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
h4{font-size:1.4375em}}
table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
table thead,table tfoot{background:#f7f8f7}
table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
table tr.even,table tr.alt{background:#f8f8f7}
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
.center{margin-left:auto;margin-right:auto}
.stretch{width:100%}
.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
.clearfix::after,.float-group::after{clear:both}
:not(pre).nobreak{word-wrap:normal}
:not(pre).nowrap{white-space:nowrap}
:not(pre).pre-wrap{white-space:pre-wrap}
:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
pre>code{display:block}
pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
em em{font-style:normal}
strong strong{font-weight:400}
.keyseq{color:rgba(51,51,51,.8)}
kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
.keyseq kbd:first-child{margin-left:0}
.keyseq kbd:last-child{margin-right:0}
.menuseq,.menuref{color:#000}
.menuseq b:not(.caret),.menuref{font-weight:inherit}
.menuseq{word-spacing:-.02em}
.menuseq b.caret{font-size:1.25em;line-height:.8}
.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
b.button::before{content:"[";padding:0 3px 0 2px}
b.button::after{content:"]";padding:0 2px 0 3px}
p a>code:hover{color:rgba(0,0,0,.9)}
#header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
#content{margin-top:1.25em}
#content::before{content:none}
#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
#header>h1:only-child{border-bottom:1px solid #dddddf;padding-bottom:8px}
#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
#header .details span:first-child{margin-left:-.125em}
#header .details span.email a{color:rgba(0,0,0,.85)}
#header .details br{display:none}
#header .details br+span::before{content:"\00a0\2013\00a0"}
#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
#header .details br+span#revremark::before{content:"\00a0|\00a0"}
#header #revnumber{text-transform:capitalize}
#header #revnumber::after{content:"\00a0"}
#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
#toc>ul{margin-left:.125em}
#toc ul.sectlevel0>li>a{font-style:italic}
#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
#toc li{line-height:1.3334;margin-top:.3334em}
#toc a{text-decoration:none}
#toc a:active{text-decoration:underline}
#toctitle{color:#7a2518;font-size:1.2em}
@media screen and (min-width:768px){#toctitle{font-size:1.375em}
body.toc2{padding-left:15em;padding-right:0}
body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
#toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
#toc.toc2>ul{font-size:.9em;margin-bottom:0}
#toc.toc2 ul ul{margin-left:0;padding-left:1em}
#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
body.toc2.toc-right{padding-left:0;padding-right:15em}
body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
#toc.toc2{width:20em}
#toc.toc2 #toctitle{font-size:1.375em}
#toc.toc2>ul{font-size:.95em}
#toc.toc2 ul ul{padding-left:1.25em}
body.toc2.toc-right{padding-left:0;padding-right:20em}}
#content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
#content #toc>:first-child{margin-top:0}
#content #toc>:last-child{margin-bottom:0}
#footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
#footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
#content{margin-bottom:.625em}
.sect1{padding-bottom:.625em}
@media screen and (min-width:768px){#content{margin-bottom:1.25em}
.sect1{padding-bottom:1.25em}}
.sect1:last-child{padding-bottom:0}
.sect1+.sect1{border-top:1px solid #e7e7e9}
#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
details{margin-left:1.25rem}
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
details>summary::-webkit-details-marker{display:none}
details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
.paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
.admonitionblock>table td.icon{text-align:center;width:80px}
.admonitionblock>table td.icon img{max-width:none}
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
.exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
.sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
.exampleblock>.content>:first-child,.sidebarblock>.content>:first-child{margin-top:0}
.exampleblock>.content>:last-child,.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
.literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
@media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
@media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
.literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
.listingblock>.content{position:relative}
.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
.listingblock:hover code[data-lang]::before{display:block}
.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
.listingblock pre.highlightjs{padding:0}
.listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
.listingblock pre.prettyprint{border-width:0}
.prettyprint{background:#f7f7f8}
pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
pre.prettyprint li code[data-lang]::before{opacity:1}
pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
table.linenotable td.code{padding-left:.75em}
table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
pre.pygments span.linenos{display:inline-block;margin-right:.75em}
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
.quoteblock blockquote{margin:0;padding:0;border:0}
.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
.verseblock{margin:0 1em 1.25em}
.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
.verseblock pre strong{font-weight:400}
.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
.quoteblock .attribution br,.verseblock .attribution br{display:none}
.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
.quoteblock.abstract{margin:0 1em 1.25em;display:block}
.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
.quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
.quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
p.tableblock:last-child{margin-bottom:0}
td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
td.tableblock>.content>:last-child{margin-bottom:-1.25em}
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
table.grid-all>*>tr>*{border-width:1px}
table.grid-cols>*>tr>*{border-width:0 1px}
table.grid-rows>*>tr>*{border-width:1px 0}
table.frame-all{border-width:1px}
table.frame-ends{border-width:1px 0}
table.frame-sides{border-width:0 1px}
table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
th.halign-left,td.halign-left{text-align:left}
th.halign-right,td.halign-right{text-align:right}
th.halign-center,td.halign-center{text-align:center}
th.valign-top,td.valign-top{vertical-align:top}
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
th.valign-middle,td.valign-middle{vertical-align:middle}
table thead th,table tfoot th{font-weight:bold}
tbody tr th{background:#f7f8f7}
tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
p.tableblock>code:only-child{background:none;padding:0}
p.tableblock{font-size:1em}
ol{margin-left:1.75em}
ul li ol{margin-left:1.5em}
dl dd{margin-left:1.125em}
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
ul.unstyled,ol.unstyled{margin-left:0}
li>p:empty:only-child::before{content:"";display:inline-block}
ul.checklist>li>p:first-child{margin-left:-1em}
ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
ul.inline>li{margin-left:1.25em}
.unstyled dl dt{font-weight:400;font-style:normal}
ol.arabic{list-style-type:decimal}
ol.decimal{list-style-type:decimal-leading-zero}
ol.loweralpha{list-style-type:lower-alpha}
ol.upperalpha{list-style-type:upper-alpha}
ol.lowerroman{list-style-type:lower-roman}
ol.upperroman{list-style-type:upper-roman}
ol.lowergreek{list-style-type:lower-greek}
.hdlist>table,.colist>table{border:0;background:none}
.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
td.hdlist1{font-weight:bold;padding-bottom:1.25em}
td.hdlist2{word-wrap:anywhere}
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
.colist td:not([class]):first-child img{max-width:none}
.colist td:not([class]):last-child{padding:.25em 0}
.thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
.imageblock.left{margin:.25em .625em 1.25em 0}
.imageblock.right{margin:.25em 0 1.25em .625em}
.imageblock>.title{margin-bottom:0}
.imageblock.thumb,.imageblock.th{border-width:6px}
.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
.image.left{margin-right:.625em}
.image.right{margin-left:.625em}
a.image{text-decoration:none;display:inline-block}
a.image object{pointer-events:none}
sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
sup.footnote a,sup.footnoteref a{text-decoration:none}
sup.footnote a:active,sup.footnoteref a:active,#footnotes .footnote a:first-of-type:active{text-decoration:underline}
#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
#footnotes .footnote:last-of-type{margin-bottom:0}
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
div.unbreakable{page-break-inside:avoid}
.big{font-size:larger}
.small{font-size:smaller}
.underline{text-decoration:underline}
.overline{text-decoration:overline}
.line-through{text-decoration:line-through}
.aqua{color:#00bfbf}
.aqua-background{background:#00fafa}
.black{color:#000}
.black-background{background:#000}
.blue{color:#0000bf}
.blue-background{background:#0000fa}
.fuchsia{color:#bf00bf}
.fuchsia-background{background:#fa00fa}
.gray{color:#606060}
.gray-background{background:#7d7d7d}
.green{color:#006000}
.green-background{background:#007d00}
.lime{color:#00bf00}
.lime-background{background:#00fa00}
.maroon{color:#600000}
.maroon-background{background:#7d0000}
.navy{color:#000060}
.navy-background{background:#00007d}
.olive{color:#606000}
.olive-background{background:#7d7d00}
.purple{color:#600060}
.purple-background{background:#7d007d}
.red{color:#bf0000}
.red-background{background:#fa0000}
.silver{color:#909090}
.silver-background{background:#bcbcbc}
.teal{color:#006060}
.teal-background{background:#007d7d}
.white{color:#bfbfbf}
.white-background{background:#fafafa}
.yellow{color:#bfbf00}
.yellow-background{background:#fafa00}
span.icon>.fa{cursor:default}
a span.icon>.fa{cursor:inherit}
.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
.conum[data-value] *{color:#fff!important}
.conum[data-value]+b{display:none}
.conum[data-value]::after{content:attr(data-value)}
pre .conum[data-value]{position:relative;top:-.125em}
b.conum *{color:inherit!important}
.conum:not([data-value]):empty{display:none}
dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
p,blockquote,dt,td.content,td.hdlist1,span.alt,summary{font-size:1.0625rem}
p{margin-bottom:1.25rem}
.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
.exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
.print-only{display:none!important}
@page{margin:1.25cm .75cm}
@media print{*{box-shadow:none!important;text-shadow:none!important}
html{font-size:80%}
a{color:inherit!important;text-decoration:underline!important}
a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
abbr[title]{border-bottom:1px dotted}
abbr[title]::after{content:" (" attr(title) ")"}
pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
thead{display:table-header-group}
svg{max-width:100%}
p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
#header,#content,#footnotes,#footer{max-width:none}
#toc,.sidebarblock,.exampleblock>.content{background:none!important}
#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
body.book #header{text-align:center}
body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
body.book #header .details{border:0!important;display:block;padding:0!important}
body.book #header .details span:first-child{margin-left:0!important}
body.book #header .details br{display:block}
body.book #header .details br+span::before{content:none!important}
body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
.listingblock code[data-lang]::before{display:block}
#footer{padding:0 .9375em}
.hide-on-print{display:none!important}
.print-only{display:block!important}
.hide-for-print{display:none!important}
.show-for-print{display:inherit!important}}
@media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
.sect1{padding:0!important}
.sect1+.sect1{border:0}
#footer{background:none}
#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
</style>
</head>
<body class="article toc2 toc-left">
<div id="header">
<h1>fok-js使用手册</h1>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="#_使用">使用</a>
<ul class="sectlevel2">
<li><a href="#_线上地址">线上地址</a>
<ul class="sectlevel3">
<li><a href="#_步骤一拉取">步骤一：拉取</a></li>
<li><a href="#_步骤二引入">步骤二：引入</a></li>
<li><a href="#_步骤三使用">步骤三：使用</a></li>
</ul>
</li>
<li><a href="#_本地包">本地包</a>
<ul class="sectlevel3">
<li><a href="#_步骤一拷贝包">步骤一：拷贝包</a></li>
<li><a href="#_步骤二本地引入包">步骤二：本地引入包</a>
<ul class="sectlevel4">
<li><a href="#_方式一file格式安装">方式一：file格式安装</a></li>
<li><a href="#_方式二相对路径安装">方式二：相对路径安装</a></li>
</ul>
</li>
<li><a href="#_步骤二引入_2">步骤二：引入</a></li>
<li><a href="#_步骤三使用_2">步骤三：使用</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#_字符串">字符串</a>
<ul class="sectlevel2">
<li><a href="#_camelcase_转驼峰">camelCase 转驼峰</a></li>
<li><a href="#_kebabcase_转烤肉串">kebabCase 转烤肉串</a></li>
<li><a href="#_snakecase_转下划线">snakeCase 转下划线</a></li>
<li><a href="#_upperfirst_转首字母大写">upperFirst 转首字母大写</a></li>
<li><a href="#_digituppercase_金额小写转大写">digitUppercase 金额小写转大写</a></li>
<li><a href="#_deduplication_字符串去重">deduplication 字符串去重</a></li>
<li><a href="#_ishasillegalchar_检测是否包含非法字符">isHasIllegalChar 检测是否包含非法字符</a></li>
</ul>
</li>
<li><a href="#_数组">数组</a>
<ul class="sectlevel2">
<li><a href="#_arraycompact_过滤空值">arrayCompact 过滤空值</a></li>
<li><a href="#_arrayflattendeep_拉平多维数组">arrayFlattenDeep 拉平多维数组</a></li>
<li><a href="#_arrayunion_数组取并集">arrayUnion 数组取并集</a></li>
<li><a href="#_arraypull_删除元素">arrayPull 删除元素</a></li>
<li><a href="#_arraypullall_删除数组元素">arrayPullAll 删除数组元素</a></li>
<li><a href="#_arraydeduplication_数组去重">arrayDeduplication 数组去重</a></li>
<li><a href="#_foreachtree_遍历tree结构数据">forEachTree 遍历tree结构数据</a></li>
</ul>
</li>
<li><a href="#_函数">函数</a>
<ul class="sectlevel2">
<li><a href="#_debounce_防抖">debounce 防抖</a></li>
<li><a href="#_throttle_节流">throttle 节流</a></li>
</ul>
</li>
<li><a href="#_格式">格式</a>
<ul class="sectlevel2">
<li><a href="#_formatnumbertomonetization_数字货币化千分位">formatNumberToMonetization 数字货币化千分位</a></li>
<li><a href="#_formatnumbertothousand_数字千分位">formatNumberToThousand 数字千分位</a></li>
</ul>
</li>
<li><a href="#_对象">对象</a>
<ul class="sectlevel2">
<li><a href="#_hasownprop_判断对象自身属性中是否具有指定的属性">hasOwnProp 判断对象自身属性中是否具有指定的属性</a></li>
<li><a href="#_hasownval_判断对象是否包含该值">hasOwnVal 判断对象是否包含该值</a></li>
<li><a href="#_isemptyobject_判断对象是否为空">isEmptyObject 判断对象是否为空</a></li>
</ul>
</li>
<li><a href="#_时间">时间</a>
<ul class="sectlevel2">
<li><a href="#_获取时间实例">获取时间实例</a></li>
<li><a href="#_获取毫秒">获取毫秒</a></li>
<li><a href="#_获取秒">获取秒</a></li>
<li><a href="#_获取分钟">获取分钟</a></li>
<li><a href="#_获取小时">获取小时</a></li>
<li><a href="#_获取日期">获取日期</a></li>
<li><a href="#_获取星期">获取星期</a></li>
<li><a href="#_获取月">获取月</a></li>
<li><a href="#_获取年">获取年</a></li>
<li><a href="#_设置时间">设置时间</a></li>
<li><a href="#_时间相加">时间相加</a></li>
<li><a href="#_时间相减">时间相减</a></li>
<li><a href="#_时间加减链式调用">时间加减链式调用</a></li>
<li><a href="#_格式化">格式化</a></li>
<li><a href="#_判断是否为闰年">判断是否为闰年</a></li>
<li><a href="#_formatpasstime_格式化距现在的已过时间">formatPassTime 格式化距现在的已过时间</a></li>
<li><a href="#_formatremaintime_格式化现在距指定时间的剩余时间">formatRemainTime 格式化现在距指定时间的剩余时间</a></li>
<li><a href="#_formattimestamp_时间戳格式化">formatTimeStamp 时间戳格式化</a></li>
<li><a href="#_monthdays_获取指定月份的天数">monthDays 获取指定月份的天数</a></li>
<li><a href="#_timeleft_计算剩余时间">timeLeft 计算剩余时间</a></li>
<li><a href="#_getbeforedays_获取某天之前的几天">getBeforeDays 获取某天之前的几天</a></li>
<li><a href="#_getafterdays_获取某天之后的几天">getAfterDays 获取某天之后的几天</a></li>
<li><a href="#_getlastweek_获取上周">getLastWeek 获取上周</a></li>
<li><a href="#_getthisweek_获取本周">getThisWeek 获取本周</a></li>
<li><a href="#_getnextweek_获取下周">getNextWeek 获取下周</a></li>
</ul>
</li>
<li><a href="#_正则">正则</a>
<ul class="sectlevel2">
<li><a href="#_iscolor_是否为颜色值">isColor 是否为颜色值</a></li>
<li><a href="#_ishexcolor_是否为16进制颜色值">isHexColor 是否为16进制颜色值</a></li>
<li><a href="#_isemail_是否为邮箱">isEmail 是否为邮箱</a></li>
<li><a href="#_isidcard_是否为身份证号">isIdCard 是否为身份证号</a></li>
<li><a href="#_isphoneno_判断是否为手机号">isPhoneNo 判断是否为手机号</a></li>
<li><a href="#_istelephoneno_判断是否为座机号">istelephoneNo 判断是否为座机号</a></li>
<li><a href="#_isip_判断是否为ip地址">isIp 判断是否为ip地址</a></li>
<li><a href="#_isurl_判断是否为url地址">isUrl 判断是否为URL地址</a></li>
<li><a href="#_ispositiveinteger_判断是否为正整数">isPositiveInteger 判断是否为正整数</a></li>
</ul>
</li>
<li><a href="#_工具">工具</a>
<ul class="sectlevel2">
<li><a href="#_数据处理">数据处理</a>
<ul class="sectlevel3">
<li><a href="#_clone_浅拷贝">clone 浅拷贝</a></li>
<li><a href="#_clonedeep_深拷贝">cloneDeep 深拷贝</a></li>
<li><a href="#_base64urltoblob_将base64图片url转换为blob流">base64UrlToBlob 将base64图片URL转换为Blob流</a></li>
<li><a href="#_blobtobase64_将blob流转换为base64图片url">blobToBase64 将Blob流转换为base64图片URL</a></li>
<li><a href="#_blobdownload_blob文件下载">blobDownload blob文件下载</a></li>
<li><a href="#_topinyin_生成拼音码">toPinyin 生成拼音码</a></li>
</ul>
</li>
<li><a href="#_数据校验">数据校验</a>
<ul class="sectlevel3">
<li><a href="#_eq_是否相等">eq 是否相等</a></li>
<li><a href="#_isstring_是否是字符串">isString 是否是字符串</a></li>
<li><a href="#_isboolean_是否是布尔值">isBoolean 是否是布尔值</a></li>
<li><a href="#_isobject_是否是对象">isObject 是否是对象</a></li>
<li><a href="#_isfunction_是否是函数">isFunction 是否是函数</a></li>
<li><a href="#_isarray_是否是数组">isArray 是否是数组</a></li>
<li><a href="#_isnull_是否是null">isNull 是否是null</a></li>
</ul>
</li>
<li><a href="#_数据获取">数据获取</a>
<ul class="sectlevel3">
<li><a href="#_returnlistname_返回下拉列表名称">returnListName 返回下拉列表名称</a></li>
<li><a href="#_getagebyidcard_根据身份证号返回年龄">getAgeByIDcard 根据身份证号返回年龄</a></li>
<li><a href="#_getbirthdaybyidcard_根据身份证号返回出生日期">getBirthdayByIDcard 根据身份证号返回出生日期</a></li>
<li><a href="#_getgenderbyidcard_根据身份证号返回性别">getGenderByIDcard 根据身份证号返回性别</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#_样式">样式</a>
<ul class="sectlevel2">
<li><a href="#_class操作">class操作</a>
<ul class="sectlevel3">
<li><a href="#_addclass_为元素添加class">addClass 为元素添加class</a></li>
<li><a href="#_hasclass_判断元素是否有某个class">hasClass 判断元素是否有某个class</a></li>
<li><a href="#_removeclass_为元素移除class">removeClass 为元素移除class</a></li>
</ul>
</li>
<li><a href="#_样式操作">样式操作</a>
<ul class="sectlevel3">
<li><a href="#_elestylevalue_获取元素指定样式值">eleStyleValue 获取元素指定样式值</a></li>
</ul>
</li>
<li><a href="#_颜色值操作">颜色值操作</a>
<ul class="sectlevel3">
<li><a href="#_rgbtohex_将rgb颜色值转换为十六进制颜色值">rgbToHex 将RGB颜色值转换为十六进制颜色值</a></li>
<li><a href="#_hextorgb_将十六进制颜色值转换为rgb颜色值">hexToRGB 将十六进制颜色值转换为RGB颜色值</a></li>
<li><a href="#_randomcolor_随机生成颜色">randomColor 随机生成颜色</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#_bom">bom</a>
<ul class="sectlevel2">
<li><a href="#_parsequerystring_url参数转对象">parseQueryString url参数转对象</a></li>
<li><a href="#_stringfyquerystring_对象序列化">stringfyQueryString 对象序列化</a></li>
<li><a href="#_getexplore_获取浏览器类型和版本">getExplore 获取浏览器类型和版本</a></li>
<li><a href="#_getos_获取操作系统类型">getOS 获取操作系统类型</a></li>
<li><a href="#_getkeyname_根据keycode获得键名">getKeyName 根据keycode获得键名</a></li>
<li><a href="#_issupportwebp_判断浏览器是否支持webp格式图片">isSupportWebP 判断浏览器是否支持webP格式图片</a></li>
</ul>
</li>
<li><a href="#_dom">dom</a>
<ul class="sectlevel2">
<li><a href="#_getscrolltop_获取滚动条距顶部的距离">getScrollTop 获取滚动条距顶部的距离</a></li>
<li><a href="#_offset_获取一个元素的距离文档document的位置">offset 获取一个元素的距离文档(document)的位置</a></li>
<li><a href="#_scrollto_在duration时间内滚动条滚动到to指定位置">scrollTo 在${duration}时间内，滚动条滚动到${to}指定位置</a></li>
<li><a href="#_setscrolltop_设置滚动条距顶部的距离">setScrollTop 设置滚动条距顶部的距离</a></li>
</ul>
</li>
<li><a href="#_数学">数学</a>
<ul class="sectlevel2">
<li><a href="#_randomnum_生成指定范围的随机整数">randomNum 生成指定范围的随机整数</a></li>
<li><a href="#_randomstr_生成指定位数的随机字符串">randomStr 生成指定位数的随机字符串</a></li>
</ul>
</li>
<li><a href="#_硬件操作">硬件操作</a>
<ul class="sectlevel2">
<li><a href="#_print_打印">print 打印</a></li>
</ul>
</li>
<li><a href="#_服务">服务</a>
<ul class="sectlevel2">
<li><a href="#_storage_缓存">storage 缓存</a>
<ul class="sectlevel3">
<li><a href="#_getlocal_获取localstorage值">getLocal 获取localstorage值</a></li>
<li><a href="#_setlocal_设置localstorage值">setLocal 设置localstorage值</a></li>
<li><a href="#_getsession_获取sessionstorage值">getSession 获取sessionstorage值</a></li>
<li><a href="#_setsession_设置sessionstorage值">setSession 设置sessionstorage值</a></li>
<li><a href="#_removelocal_删除localstorage值">removeLocal 删除localstorage值</a></li>
<li><a href="#_removesession_删除sessionstorage值">removeSession 删除sessionstorage值</a></li>
<li><a href="#_clearlocal_删除全部localstorage值">clearLocal 删除全部localstorage值</a></li>
<li><a href="#_clearsession_删除全部sessionstorage值">clearSession 删除全部sessionstorage值</a></li>
<li><a href="#_clearall_删除全部localstorage和sessionstorage值">clearAll 删除全部localstorage和sessionstorage值</a></li>
</ul>
</li>
<li><a href="#_cookie">cookie</a>
<ul class="sectlevel3">
<li><a href="#_getcookie_根据name读取cookie">getCookie 根据name读取cookie</a></li>
<li><a href="#_setcookie_设置cookie">setCookie 设置Cookie</a></li>
<li><a href="#_removecookie_根据name删除cookie">removeCookie 根据name删除cookie</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div class="sect1">
<h2 id="_使用">使用</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_线上地址">线上地址</h3>
<div class="sect3">
<h4 id="_步骤一拉取">步骤一：拉取</h4>
<div class="paragraph">
<p>进入你的工程目录，执行以下指令完成拉取。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-shell" data-lang="shell">npm install fok-js</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_步骤二引入">步骤二：引入</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import * as fokJs from "fok-js";
或者
import { digitUppercase } from "fok-js"; //建议使用结构写法，更简洁</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_步骤三使用">步骤三：使用</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import * as fokJs from "fok-js";

console.log(fokJs.digitUppercase(11.25));
或者
console.log(digitUppercase(11.25));
//壹拾壹元贰角伍分</code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_本地包">本地包</h3>
<div class="sect3">
<h4 id="_步骤一拷贝包">步骤一：拷贝包</h4>
<div class="paragraph">
<p>在dist目录下新建fok-js文件夹，把包文件拷贝过来。</p>
</div>
<div class="paragraph">
<p>包文件包含以下3部分；</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>fok-js.js</p>
</li>
<li>
<p>fok-js-0.0.0-bate.18.tgz</p>
</li>
<li>
<p>package.json</p>
</li>
</ol>
</div>
</div>
<div class="sect3">
<h4 id="_步骤二本地引入包">步骤二：本地引入包</h4>
<div class="paragraph">
<p>本地引入有两种方式。</p>
</div>
<div class="sect4">
<h5 id="_方式一file格式安装">方式一：file格式安装</h5>
<div class="paragraph">
<p>在项目package.json的dependencies下手动添加</p>
</div>
<div class="literalblock">
<div class="content">
<pre>"fok-js": "file:./dist/fok-js/",</pre>
</div>
</div>
<div class="paragraph">
<p>并安装</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-shell" data-lang="shell">npm install</code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="_方式二相对路径安装">方式二：相对路径安装</h5>
<div class="paragraph">
<p>使用如下命令直接安装：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-shell" data-lang="shell">npm install ./dist/fok-js/</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
两种方式都会在本地node_modules下生成fok-js文件夹，移除包使用remove命令即可。
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_步骤二引入_2">步骤二：引入</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import * as fokJs from "fok-js";
或者
import { digitUppercase } from "fok-js";</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_步骤三使用_2">步骤三：使用</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import * as fokJs from "fok-js";

console.log(fokJs.digitUppercase(11.25));
或者
console.log(digitUppercase(11.25));
//壹拾壹元贰角伍分</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_字符串">字符串</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_camelcase_转驼峰">camelCase 转驼峰</h3>
<div class="paragraph">
<p>转换字符串string为驼峰写法。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { camelCase } from "fok-js";

console.log(camelCase('Foo Bar'));
// 'fooBar'
console.log(camelCase('--foo-bar--'));
// 'fooBar'
console.log(camelCase('__FOO_BAR__'));
// 'fooBar'</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_kebabcase_转烤肉串">kebabCase 转烤肉串</h3>
<div class="paragraph">
<p>转换字符串string为kebab case。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { kebabCase } from "fok-js";

console.log(kebabCase('Foo Bar'));
// 'foo-bar'
console.log(kebabCase('fooBar'));
// 'foo-bar'
console.log(kebabCase('__FOO_BAR__'));
// 'foo-bar'</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_snakecase_转下划线">snakeCase 转下划线</h3>
<div class="paragraph">
<p>转换字符串string为snake case。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { snakeCase } from "fok-js";

console.log(snakeCase('Foo Bar'));
// 'foo_bar'
console.log(snakeCase('fooBar'));
// 'foo_bar'
console.log(snakeCase('--FOO-BAR--'));
// 'foo_bar'</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_upperfirst_转首字母大写">upperFirst 转首字母大写</h3>
<div class="paragraph">
<p>转换字符串string为snake case。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { upperFirst } from "fok-js";

console.log(upperFirst('fred'));
// 'Fred'
console.log(upperFirst('FRED'));
// 'FRED'
console.log(upperFirst('foo bar'));
// 'Foo bar'</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_digituppercase_金额小写转大写">digitUppercase 金额小写转大写</h3>
<div class="paragraph">
<p>转换字符串string为snake case。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { digitUppercase } from "fok-js";

console.log(digitUppercase(11.25));
// 壹拾壹元贰角伍分</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_deduplication_字符串去重">deduplication 字符串去重</h3>
<div class="paragraph">
<p>去除字符串中的重复字符，并返回一个新的字符串。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { deduplication } from "fok-js";

let str = '123addf2..@@';
console.log(deduplication(str));
//123adf.@</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_ishasillegalchar_检测是否包含非法字符">isHasIllegalChar 检测是否包含非法字符</h3>
<div class="paragraph">
<p>检测是否包含非法字符，返回一个描述对象。
匹配不区分大小写，进行完全匹配，支持多行匹配。
返回对象的subStringResult表示对整个subString的检测结果，contains表示是否包含，count是出现次数，positions表示出现的位置。
overallResult数组是对subString中单个字符的的检测结果，数组元素为对象，character表示当前检测字符，contains表示是否包含，count是出现次数，positions表示出现的位置。
isHasIllegalChar方法还支持第三个参数type，默认值是&#8217;str'，表示subString为字符串。可选值是&#8217;reg'，表示subString为正则表达式，如果'[a-z]'。如果type为&#8217;reg&#8217;时，subString为错误的正则表达式，则直接返回匹配结果，结果为没有。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isHasIllegalChar } from "fok-js";

let mainString = "这是一个aer示例字\n符串，包含要123检查的,./内容。要检\n查的内@#$容可3245能会出现ASD多次。";
let subString = "aer示例x,d";
// 使用字符串匹配
let resultStr = isHasIllegalChar(mainString, subString);
console.log(resultStr);</code></pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="../../img/isHasIllegalChar1.png" alt="isHasIllegalChar1">
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isHasIllegalChar } from "fok-js";

let mainString = "这是一个aer示例字\n符串，包含要123检查的,./内容。要检\n查的内@#$容可3245能会出现ASD多次。";
let subString = "er示例";
// 使用字符串匹配
let resultStr = isHasIllegalChar(mainString, subString);
console.log(resultStr);</code></pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="../../img/isHasIllegalChar2.png" alt="isHasIllegalChar2">
</div>
</div>
<div class="listingblock">
<div class="content">
<pre>import { isHasIllegalChar } from "fok-js";

let mainString = "这是一个aer示例字\n符串，包含要123检查的,./内容。要检\n查的内@#$容可3245能会出现ASD多次。";
let subStringReg = "[a-z]";
// 使用正则表达式匹配
let resultReg = isHasIllegalChar(mainString, subStringReg, 'reg');
console.log(resultReg);</pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="../../img/isHasIllegalChar3.png" alt="isHasIllegalChar3">
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_数组">数组</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_arraycompact_过滤空值">arrayCompact 过滤空值</h3>
<div class="paragraph">
<p>空值一般为false、null、0、""、undefined、和 NaN。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { arrayCompact } from "fok-js";

console.log(arrayCompact([0, 1, false, 2, '', 3]));
// [1, 2, 3]</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_arrayflattendeep_拉平多维数组">arrayFlattenDeep 拉平多维数组</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { arrayFlattenDeep } from "fok-js";

console.log(arrayFlattenDeep([1, [2, [3, [4]], 5]]));
// [1, 2, 3, 4, 5]</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_arrayunion_数组取并集">arrayUnion 数组取并集</h3>
<div class="paragraph">
<p>创建一个按顺序排列的唯一值的数组。所有给定数组的元素值使用SameValueZero做等值比较。（注： arrays（数组）的并集，按顺序返回，返回数组的元素是唯一的）。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { arrayUnion } from "fok-js";

console.log(arrayUnion([2], [1, 2]));
// [2, 1]</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_arraypull_删除元素">arrayPull 删除元素</h3>
<div class="paragraph">
<p>移除数组array中所有和给定值相等的元素,这个方法会改变数组。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { arrayPull } from "fok-js";

let array = [1, 2, 3, 1, 2, 3];
arrayPull(array, 2, 3);
console.log(array);
// [1, 1]</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_arraypullall_删除数组元素">arrayPullAll 删除数组元素</h3>
<div class="paragraph">
<p>移除数组array中所有和给定数组值相等的元素,这个方法不会改变数组。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { arrayPullAll } from "fok-js";

let array = [1, 2, 3, 1, 2, 3];
arrayPullAll(array, [2, 1]);
console.log(array);
// [3, 3]</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_arraydeduplication_数组去重">arrayDeduplication 数组去重</h3>
<div class="paragraph">
<p>删除数组中的重复元素，并返回一个新的数组。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { arrayDeduplication } from "fok-js";

let array = [1, 2, 3, 1, 2, 3];
console.log(arrayDeduplication(array));
// [1, 2, 3]
let array = ['sdf', 'fef', 123, false, 'fef', false];
console.log(arrayDeduplication(array));
// ['sdf', 'fef', 123, false]</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_foreachtree_遍历tree结构数据">forEachTree 遍历tree结构数据</h3>
<div class="paragraph">
<p>遍历tree结构数据</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { forEachTree } from "fok-js";

forEachTree([],(item,index,parent)=&gt;{
  console.log(item,index,parent);
},'children');</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_函数">函数</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_debounce_防抖">debounce 防抖</h3>
<div class="ulist">
<ul>
<li>
<p>当事件触发时，相应的函数并不会立即触发，而是会等待一定的时间；</p>
</li>
<li>
<p>当事件密集触发时，函数的触发会被频繁的推迟；</p>
</li>
<li>
<p>只有等待了一段时间也没有事件触发，才会真正的执行响应函数。</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;div class="page-content"&gt;
    &lt;button @click="debounceFn()"&gt;点击我&lt;/button&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script lang="ts"&gt;
  import { defineComponent, ref } from 'vue';
  import { debounce } from "fok-js";

  export default defineComponent({
    components: {  },
    setup() {
      //常规使用
      let debounceFn = debounce(clickTest, 1000);
      //立即执行
      // let debounceFn = debounce(clickTest, 1000, true);
      //取消执行
      // debounceFn.cancel();

      debounceFn();

      function clickTest() {
        console.log('123');
      }
      return {
        clickTest,
        debounceFn
      };
    },
  });
&lt;/script&gt;

&lt;style lang="less" scoped&gt;
  .page-content {
    padding: 16px;
  }
&lt;/style&gt;</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 1. 防抖参数</caption>
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
<th class="tableblock halign-left valign-top">是否必传</th>
<th class="tableblock halign-left valign-top">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">需要防抖的函数</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">delay</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Number</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">延迟时间</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">immediately</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是否立即执行</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 2. 防抖返回值</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">新的防抖函数</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_throttle_节流">throttle 节流</h3>
<div class="ulist">
<ul>
<li>
<p>当事件触发时，相应的函数并不会立即触发，而是会等待一定的时间；</p>
</li>
<li>
<p>当事件密集触发时，函数的触发会被频繁的推迟；</p>
</li>
<li>
<p>只有等待了一段时间也没有事件触发，才会真正的执行响应函数。</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;div class="page-content"&gt;
    &lt;button @click="throttleFn()"&gt;点击我&lt;/button&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script lang="ts"&gt;
  import { defineComponent, ref } from 'vue';
  import { throttle } from "fok-js";

  export default defineComponent({
    components: {  },
    setup() {
      //常规使用
      let throttleFn = throttle(clickTest, 3000);
      //首次不触发和最后结束触发
      //e.g. 首次不触发leading和最后结束触发trailing: options = { leading: true, trailing: false }
      // let throttleFn = throttle(clickTest, 3000, { leading: true, trailing: false });

      throttleFn();

      function clickTest() {
        console.log('123');
      }
      return {
        clickTest,
        throttleFn
      };
    },
  });
&lt;/script&gt;

&lt;style lang="less" scoped&gt;
  .page-content {
    padding: 16px;
  }
&lt;/style&gt;</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 3. 节流参数</caption>
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
<th class="tableblock halign-left valign-top">是否必传</th>
<th class="tableblock halign-left valign-top">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">需要节流的函数</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">interval</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Number</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">间隔时间</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">options</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Object</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">节流配置</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">{ leading: true, trailing: false }</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 4. 节流返回值</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Function</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">新的节流函数</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_格式">格式</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_formatnumbertomonetization_数字货币化千分位">formatNumberToMonetization 数字货币化千分位</h3>
<div class="paragraph">
<p>默认2位小数</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { formatNumberToMonetization } from "fok-js";

console.log(formatNumberToMonetization(123456));
// ￥123,456.00</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_formatnumbertothousand_数字千分位">formatNumberToThousand 数字千分位</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { formatNumberToThousand } from "fok-js";

console.log(formatNumberToThousand(123456));
// 123,456.00</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_对象">对象</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_hasownprop_判断对象自身属性中是否具有指定的属性">hasOwnProp 判断对象自身属性中是否具有指定的属性</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { hasOwnProp } from "fok-js";

let obj = {
  a: 1,
  b: 2
};
console.log(hasOwnProp(obj, 'a'));
//true
console.log(hasOwnProp(obj, 'toString'));
//false</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_hasownval_判断对象是否包含该值">hasOwnVal 判断对象是否包含该值</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { hasOwnVal } from "fok-js";

let obj = {
  a: 1,
  b: 2
};
console.log(hasOwnVal(obj, 2));
//true
console.log(hasOwnVal(obj, '2'));
//false</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_isemptyobject_判断对象是否为空">isEmptyObject 判断对象是否为空</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isEmptyObject } from "fok-js";

let obj = {};
let obj1 = {
  a: 1,
  b: 2
};
console.log(isEmptyObject(obj));
//true
console.log(isEmptyObject(obj1));
//false</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_时间">时间</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_获取时间实例">获取时间实例</h3>
<div class="paragraph">
<p>直接使用dayjs()方法，等同于 dayjs(new Date()) 的调用。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs());
// Dayjs2类型对象</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取毫秒">获取毫秒</h3>
<div class="paragraph">
<p>值为0到999。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().millisecond());
// 995</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取秒">获取秒</h3>
<div class="paragraph">
<p>值为0到59。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().second());
// 6</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取分钟">获取分钟</h3>
<div class="paragraph">
<p>值为0到59。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().minute());
// 32</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取小时">获取小时</h3>
<div class="paragraph">
<p>值为0到23。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().hour());
// 11</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取日期">获取日期</h3>
<div class="paragraph">
<p>值为1到31。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().date());
// 23</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取星期">获取星期</h3>
<div class="paragraph">
<p>值为0(星期天)到6(星期六)。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().day());
// 1</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取月">获取月</h3>
<div class="paragraph">
<p>值为0到11。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().month());
// 9</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_获取年">获取年</h3>
<div class="paragraph">
<p>值为0到11。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().year());
// 2023</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_设置时间">设置时间</h3>
<div class="paragraph">
<p>同获取各种时间方法，区别是需要传入参数值。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().year(2000));
// 设置年</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_时间相加">时间相加</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().add(7, 'day'));
// Dayjs2时间对象</code></pre>
</div>
</div>
<div class="paragraph">
<p>各个传入的单位对大小写不敏感，支持缩写和复数。 请注意，缩写是区分大小写的。</p>
</div>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 5. 支持的单位列表</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">单位</th>
<th class="tableblock halign-left valign-top">缩写</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">day</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">d</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">日</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">week</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">w</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">周</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">month</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">M</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">月份(0-11)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">year</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">y</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">年</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hour</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">h</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">小时</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">minute</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">m</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">分钟</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">second</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">秒</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">millisecond</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毫秒</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_时间相减">时间相减</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs().subtract(7, 'day'));
// Dayjs2时间对象</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_时间加减链式调用">时间加减链式调用</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs('2019-01-25').add(1, 'day').subtract(1, 'year').year(2009).toString());
// Sun, 25 Jan 2009 16:00:00 GMT</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_格式化">格式化</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

// 默认返回的是 ISO8601 格式字符串
console.log(dayjs().format());
// 2023-10-23T11:55:27+08:00
console.log(dayjs('2019-01-25').format('DD/MM/YYYY'))
// 25/01/2019
console.log(dayjs().format('YYYY-MM-DD HH:mm:ss')) //24小时制
// 2023-10-23 13:33:34
console.log(dayjs().format('YYYY-MM-DD hh:mm:ss')) //12小时制
// 2023-10-23 01:34:03</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 6. 支持的格式化占位符列表</caption>
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">标识</th>
<th class="tableblock halign-left valign-top">示例</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">YY</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">18</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">年，两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">YYYY</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2018</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">年，四位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1-12</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">月,从1开始</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">MM</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01-12</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">月，两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">MMM</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Jan-Dec</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">月，英文缩写</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">D</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1-31</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">日</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">DD</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01-31</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">日，两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">d</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0-6</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">一周中的一天，星期天是 0</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">dd</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Su-Sa</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">最简写的星期几</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ddd</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Sun-Sat</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">简写的星期几</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">dddd</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Sunday-Saturday</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">星期几，英文全称</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">H</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0-23</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">小时，24小时制,一位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">HH</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">00-23</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">小时，24小时制,两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">h</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1-12</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">小时, 12小时制,一位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hh</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01-12</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">小时, 12小时制,两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">m</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0-59</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">分钟</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">mm</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">00-59</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">分钟，两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0-59</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">秒</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ss</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">00-59</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">秒，两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">S</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0-9</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毫秒(十),一位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">SS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">00-99</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毫秒(百),两位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">SSS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">000-999</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毫秒,三位数</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Z</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">-05:00</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">UTC 的偏移量，±HH:mm</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ZZ</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">-0500</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">UTC 的偏移量，±HHmm</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">A</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">AM / PM</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">上/下午,大写</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">a</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">am / pm</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">上/下午,小写</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Do</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st&#8230;&#8203; 31st</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">月份的日期与序号</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_判断是否为闰年">判断是否为闰年</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { dayjs } from "fok-js";

console.log(dayjs('2001-01-01').isLeapYear());
//false
console.log(dayjs('2000-01-01').isLeapYear());
//true</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_formatpasstime_格式化距现在的已过时间">formatPassTime 格式化距现在的已过时间</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { formatPassTime } from "fok-js";

console.log(formatPassTime(new Date('2013-10-02')));
//10年前
console.log(formatPassTime(new Date('2023-10-02')));
//3个月前
console.log(formatPassTime(new Date('2033-10-02')));
//-9年前</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_formatremaintime_格式化现在距指定时间的剩余时间">formatRemainTime 格式化现在距指定时间的剩余时间</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { formatRemainTime } from "fok-js";

console.log(formatRemainTime(new Date('2025-10-02 12:12:12')));
//636天 21小时 43分钟 46秒
console.log(formatRemainTime(new Date('2023-10-02')));
//0天 0小时 0分钟 0秒
console.log(formatRemainTime(new Date('2033-10-02')));
//3558天 17小时 33分钟 42秒</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_formattimestamp_时间戳格式化">formatTimeStamp 时间戳格式化</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { formatTimeStamp } from "fok-js";

console.log(formatTimeStamp(Date.now()));
//2024-01-04 14:48:38
console.log(formatTimeStamp(new Date().getTime()));
//2024-01-04 14:49:33
console.log(formatTimeStamp(new Date().valueOf()));
//2024-01-04 14:50:26</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_monthdays_获取指定月份的天数">monthDays 获取指定月份的天数</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { monthDays } from "fok-js";

console.log(monthDays('2001-11-01'));
//30
console.log(monthDays('2023-01-01'));
//31</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_timeleft_计算剩余时间">timeLeft 计算剩余时间</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { timeLeft } from "fok-js";

console.log(timeLeft('2023-01-01 01:02:03', '2024-05-05 04:05:06'));
//{d: 490, h: 3, m: 3, s: 3}
console.log(timeLeft('2024-05-05 01:02:03', '2023-01-01 04:05:06'));
//{d: 0, h: 0, m: 0, s: 0}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getbeforedays_获取某天之前的几天">getBeforeDays 获取某天之前的几天</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getBeforeDays } from "fok-js";

console.log(getBeforeDays('2024-01-01', 5));
//['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31', '2024-01-01']</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getafterdays_获取某天之后的几天">getAfterDays 获取某天之后的几天</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getAfterDays } from "fok-js";

console.log(getAfterDays('2023-12-31', 5));
//['2023-12-31', '2024-01-01', '2024-01-02', '2024-01-03', '2024-01-04']</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getlastweek_获取上周">getLastWeek 获取上周</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getLastWeek } from "fok-js";

console.log(getLastWeek());
//['2024-01-08', '2024-01-09', '2024-01-10', '2024-01-11', '2024-01-12', '2024-01-13', '2024-01-14']</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getthisweek_获取本周">getThisWeek 获取本周</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getThisWeek } from "fok-js";

console.log(getThisWeek());
//['2024-01-15', '2024-01-16', '2024-01-17', '2024-01-18', '2024-01-19', '2024-01-20', '2024-01-21']</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getnextweek_获取下周">getNextWeek 获取下周</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getNextWeek } from "fok-js";

console.log(getNextWeek());
//['2024-01-22', '2024-01-23', '2024-01-24', '2024-01-25', '2024-01-26', '2024-01-27', '2024-01-28']</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_正则">正则</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_iscolor_是否为颜色值">isColor 是否为颜色值</h3>
<div class="paragraph">
<p>判断当前字符串判断是否为正确的颜色值，包含16进制颜色值、rgb或rgba。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isColor } from "fok-js";

console.log(isColor('123456'));
// false
console.log(isColor('#123456'));
// true
console.log(isColor('#fff'));
// true
console.log(isColor('#FFFFFF'));
// true
console.log(isColor('#ggg'));
// false
console.log(isColor('2, 2, 2'));
// false
console.log(isColor('rgb(2, 2, 2)'));
// true
console.log(isColor('RGB(2, 2, 2)'));
// true
console.log(isColor('rgb(256, 2, 2)'));
// false
console.log(isColor('rgba(2, 2, 2, 0.5)'));
// true
console.log(isColor('RGBA(2, 2, 2, 0.5)'));
// true
console.log(isColor('rgba(2, 2, 2, 1.5)'));
// false</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_ishexcolor_是否为16进制颜色值">isHexColor 是否为16进制颜色值</h3>
<div class="paragraph">
<p>判断当前字符串判断是否为正确的16进制颜色值。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isHexColor } from "fok-js";

console.log(isHexColor('123456'));
// false
console.log(isHexColor('#123456'));
// true
console.log(isHexColor('#fff'));
// true
console.log(isHexColor('#FFF'));
// true
console.log(isHexColor('#FFF123'));
// true
console.log(isHexColor('#FFF12G'));
// false</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_isemail_是否为邮箱">isEmail 是否为邮箱</h3>
<div class="paragraph">
<p>判断当前字符串判断是否为正确的邮箱地址。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isEmail } from "fok-js";

console.log(isEmail());
// false
console.log(isEmail('123@123'));
// false
console.log(isEmail('123cn123'));
// false
console.log(isEmail('123@123.cn'));
// true
console.log(isEmail('@vip.qq.com'));
// false
console.log(isEmail('723@yahoo.com'));
// true</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_isidcard_是否为身份证号">isIdCard 是否为身份证号</h3>
<div class="paragraph">
<p>判断当前字符串判断是否为正确的身份证号。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isIdCard } from "fok-js";

console.log(isIdCard('123456'));
// 身份证号长度格式错误
console.log(isIdCard('123456789012345678'));
// 身份证号出生日期不合规
console.log(isIdCard('510824197101103465'));
//身份证号格式错误
console.log(isIdCard('510824197101107365'));
// true</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_isphoneno_判断是否为手机号">isPhoneNo 判断是否为手机号</h3>
<div class="paragraph">
<p>判断是否为手机号。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isPhoneNo } from "fok-js";

console.log(isPhoneNo('123456'));
// false
console.log(isPhoneNo('12333333333'));
// false
console.log(isPhoneNo('010-1234567'));
// false
console.log(isPhoneNo('15555555555'));
// true</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_istelephoneno_判断是否为座机号">istelephoneNo 判断是否为座机号</h3>
<div class="paragraph">
<p>判断是否为座机号。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { istelephoneNo } from "fok-js";

console.log(istelephoneNo('123456'));
// false
console.log(istelephoneNo('15555555555'));
// true
console.log(istelephoneNo('010-1234567'));
// true</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_isip_判断是否为ip地址">isIp 判断是否为ip地址</h3>
<div class="paragraph">
<p>判断是否为ip地址。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isIp } from "fok-js";

console.log(isIp('123456'));
// false
console.log(isIp('http://www'));
// false
console.log(isIp('172.168.0.1'));
// true
console.log(isIp('1.1.1.1'));
// true</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_isurl_判断是否为url地址">isUrl 判断是否为URL地址</h3>
<div class="paragraph">
<p>判断是否为URL地址。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isUrl } from "fok-js";

console.log(isUrl('123456'));
// false
console.log(isUrl('http://www'));
// false
console.log(isUrl('172.168.0.1'));
// false
console.log(isUrl('http://172.168.0.1'));
// false
console.log(isUrl('http://www.sdfde.cn'));
// true
console.log(isUrl('http://localhost:5003/#/login'));
// false</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_ispositiveinteger_判断是否为正整数">isPositiveInteger 判断是否为正整数</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">import { isPositiveInteger } from "fok-js";

console.log(isPositiveInteger(-5));
// false
console.log(isPositiveInteger(0));
// false
console.log(isPositiveInteger('q'));
// false
console.log(isPositiveInteger('1q'));
// false
console.log(isPositiveInteger(10));
// true
console.log(isPositiveInteger('10'));
// true</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_工具">工具</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_数据处理">数据处理</h3>
<div class="sect3">
<h4 id="_clone_浅拷贝">clone 浅拷贝</h4>
<div class="paragraph">
<p>这个方法参考自structured clone algorithm 以及支持 arrays、array buffers、 booleans、 date objects、maps、 numbers， Object 对象, regexes, sets, strings, symbols, 以及 typed arrays。 arguments对象的可枚举属性会拷贝为普通对象。 一些不可拷贝的对象，例如error objects、functions, DOM nodes, 以及 WeakMaps 会返回空对象。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { clone } from "fok-js";

let objects = [{ 'a': 1 }, { 'b': 2 }];
let shallow = clone(objects);
console.log(shallow[0] === objects[0]);
//true</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_clonedeep_深拷贝">cloneDeep 深拷贝</h4>
<div class="paragraph">
<p>这个方法参考自structured clone algorithm 以及支持 arrays、array buffers、 booleans、 date objects、maps、 numbers， Object 对象, regexes, sets, strings, symbols, 以及 typed arrays。 arguments对象的可枚举属性会拷贝为普通对象。 一些不可拷贝的对象，例如error objects、functions, DOM nodes, 以及 WeakMaps 会返回空对象。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { cloneDeep } from "fok-js";

let objects = [{ 'a': 1 }, { 'b': 2 }];
let deep = cloneDeep(objects);
console.log(deep[0] === objects[0]);
//false</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_base64urltoblob_将base64图片url转换为blob流">base64UrlToBlob 将base64图片URL转换为Blob流</h4>
<div class="listingblock">
<div class="content">
<pre>import { base64UrlToBlob } from "fok-js";

let base64Img = '';
console.log(`output-&gt;`, base64UrlToBlob(base64Img));</pre>
</div>
</div>
<div class="paragraph">
<p>返回一个Blob对象，Blob{size: 306, type: "image/png"}。</p>
</div>
</div>
<div class="sect3">
<h4 id="_blobtobase64_将blob流转换为base64图片url">blobToBase64 将Blob流转换为base64图片URL</h4>
<div class="listingblock">
<div class="content">
<pre>import { blobToBase64 } from "fok-js";

let base64Img = '';
let callBackFn = (data) =&gt; {
  console.log(`data-&gt;`, data);
};
blobToBase64(base64UrlToBlob(base64Img), callBackFn);
//</pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_blobdownload_blob文件下载">blobDownload blob文件下载</h4>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 7. blobDownload参数</caption>
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
<th class="tableblock halign-left valign-top">是否必传</th>
<th class="tableblock halign-left valign-top">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fileData</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">二进制</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">需下载文件的二进制</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">flieType</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">需要保存的文件类型，可选值见下</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">xlsx</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fileName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">文件名</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">未命名文件</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 8. flieType可选值</caption>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">值</th>
<th class="tableblock halign-left valign-top">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">xlsx</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">.xlsx文件</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pdf</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">.pdf文件</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">doc</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">.doc文件</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">docx</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">.docx文件</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">xls</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">.xls文件</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ppt</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">.ppt文件</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pptx</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">.pptx文件</p></td>
</tr>
</tbody>
</table>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { blobDownload } from "fok-js";

expenseExport(reqObj) //请求方法
  .then((res) =&gt; {
    blobDownload(res); //使用默认类型和默认名下载.xlsx格式文件
    blobDownload(res, 'pptx', 'pptx文件'); //指定文件类型和文件名下载.pptx格式文件
  });</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_topinyin_生成拼音码">toPinyin 生成拼音码</h4>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 9. toPinyin对象参数属性说明</caption>
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
<th class="tableblock halign-left valign-top">是否必传</th>
<th class="tableblock halign-left valign-top">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">text</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">要转换的文字</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">capital</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">首字母是否大写</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">retainNum</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是否保留数字、英文</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
</tbody>
</table>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { toPinyin } from "fok-js";

let obj = {
  text: '测试文字asd123'
};
let obj1 = {
  text: '测试文字asd123',
  capital: false,
  retainNum: false
};
console.log(toPinyin(obj));
//CeShiWenZiasd123
console.log(toPinyin(obj1));
//ceshiwenzi</code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_数据校验">数据校验</h3>
<div class="sect3">
<h4 id="_eq_是否相等">eq 是否相等</h4>
<div class="paragraph">
<p>执行SameValueZero 比较两者的值，来确定它们是否相等。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { eq } from "fok-js";

let object = { 'a': 1 };
let other = { 'a': 1 };
console.log(eq(object, object));
//true
console.log(eq(object, other));
//false
console.log(eq('a', Object('a')));
//false
console.log(eq(NaN, NaN));
//true</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_isstring_是否是字符串">isString 是否是字符串</h4>
<div class="paragraph">
<p>检查 value 是否是原始字符串String或者对象。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isString } from "fok-js";

console.log(isString('abc'));
//true
console.log(isString(1));
//false</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_isboolean_是否是布尔值">isBoolean 是否是布尔值</h4>
<div class="paragraph">
<p>检查 value 是否是原始 boolean 类型或者对象。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isBoolean } from "fok-js";

console.log(isBoolean(false));
//true
console.log(isBoolean(null));
//false</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_isobject_是否是对象">isObject 是否是对象</h4>
<div class="paragraph">
<p>检查 value 是否为 Object 的language type。 (例如： arrays, functions, objects, regexes,new Number(0), 以及 new String(''))。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isObject } from "fok-js";

console.log(isObject({}));
//true
console.log(isObject([1, 2, 3]));
//true
console.log(isObject(null));
//false</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_isfunction_是否是函数">isFunction 是否是函数</h4>
<div class="paragraph">
<p>检查 value 是否是 Function 对象。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isFunction } from "fok-js";

console.log(isFunction(() =&gt; {}));
//true
console.log(isFunction(/abc/));
//false</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_isarray_是否是数组">isArray 是否是数组</h4>
<div class="paragraph">
<p>检查 value 是否是 Array 类对象。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isArray } from "fok-js";
console.log(isArray([1, 2, 3]));
//true
console.log(isArray(document.body.children));
//false
console.log(isArray('abc'));
//false</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_isnull_是否是null">isNull 是否是null</h4>
<div class="paragraph">
<p>检查 valuealue 是否是 null。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isNull } from "fok-js";
console.log(isNull(null));
//true
console.log(isNull(void 0));
//false</code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_数据获取">数据获取</h3>
<div class="sect3">
<h4 id="_returnlistname_返回下拉列表名称">returnListName 返回下拉列表名称</h4>
<div class="paragraph">
<p>返回下拉列表名称，名称可以是label或者name。</p>
</div>
<div class="paragraph">
<p>参数有二：第一个参数是下拉列表数组，第二个是需要查询的值。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { returnListName } from "fok-js";

const classesList = [ //班次
  {
    label: '请选择',
    value: ''
  },
  {
    label: '上午',
    value: 'morning'
  },
  {
    label: '下午',
    value: 'afternoon'
  },
  {
    label: '夜班',
    value: 'nightShift'
  },
  {
    label: '全天',
    value: 'allDay'
  }
];
console.log(returnListName(classesList, 'afternoon'));
//下午</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_getagebyidcard_根据身份证号返回年龄">getAgeByIDcard 根据身份证号返回年龄</h4>
<div class="paragraph">
<p>从身份证号中返回年龄数据。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getAgeByIDcard } from "fok-js";

console.log(getAgeByIDcard('123456789012345678'));
//身份证号出生日期不合规
console.log(getAgeByIDcard('510824197101103465'));
//身份证号格式错误
console.log(getAgeByIDcard('510824197101107365'));
//52</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_getbirthdaybyidcard_根据身份证号返回出生日期">getBirthdayByIDcard 根据身份证号返回出生日期</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getBirthdayByIDcard } from "fok-js";

console.log(getBirthdayByIDcard('123456789012345678'));
//身份证号出生日期不合规
console.log(getBirthdayByIDcard('510824197101103465'));
//身份证号格式错误
console.log(getBirthdayByIDcard('510824197101107365'));
//1971-01-10</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_getgenderbyidcard_根据身份证号返回性别">getGenderByIDcard 根据身份证号返回性别</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getGenderByIDcard } from "fok-js";

console.log(getGenderByIDcard('123456789012345678'));
//身份证号出生日期不合规
console.log(getGenderByIDcard('510824197101103465'));
//身份证号格式错误
console.log(getGenderByIDcard('510824197101107365'));
//女</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_样式">样式</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_class操作">class操作</h3>
<div class="sect3">
<h4 id="_addclass_为元素添加class">addClass 为元素添加class</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;h2 ref="myH2"&gt;登录&lt;/h2&gt;
&lt;/template&gt;

&lt;script setup&gt;
import { addClass } from "fok-js";
import { ref, onMounted } from 'vue';

const myH2 = ref();
onMounted(() =&gt; {
  addClass(myH2.value, "my-h2");
});
&lt;/script&gt;
&lt;style lang="scss" scoped&gt;
 .my-h2 {
   color: red;
 }
&lt;/style&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>运行结果为h2标签增加了my-h2样式，字体变为红色。</p>
</div>
</div>
<div class="sect3">
<h4 id="_hasclass_判断元素是否有某个class">hasClass 判断元素是否有某个class</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;h2 ref="myH2"&gt;登录&lt;/h2&gt;
&lt;/template&gt;

&lt;script setup&gt;
import { addClass, hasClass } from "fok-js";
import { ref, onMounted } from 'vue';

const myH2 = ref();
onMounted(() =&gt; {
  console.log(hasClass(myH2.value, "my-h2"));
  //false
  addClass(myH2.value, "my-h2");
  console.log(hasClass(myH2.value, "my-h2"));
  //true
});
&lt;/script&gt;
&lt;style lang="scss" scoped&gt;
 .my-h2 {
   color: red;
 }
&lt;/style&gt;</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_removeclass_为元素移除class">removeClass 为元素移除class</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;h2 ref="myH2"&gt;登录&lt;/h2&gt;
&lt;/template&gt;

&lt;script setup&gt;
import { addClass, removeClass } from "fok-js";
import { ref, onMounted } from 'vue';

const myH2 = ref();
onMounted(() =&gt; {
  addClass(myH2.value, "my-h2");
  removeClass(myH2.value, "my-h2");
});
&lt;/script&gt;
&lt;style lang="scss" scoped&gt;
 .my-h2 {
   color: red;
 }
&lt;/style&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>运行结果为h2标签增加了my-h2样式，然后被移除，字体还是黑色。</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_样式操作">样式操作</h3>
<div class="sect3">
<h4 id="_elestylevalue_获取元素指定样式值">eleStyleValue 获取元素指定样式值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;h2 ref="myH2"&gt;登录&lt;/h2&gt;
&lt;/template&gt;

&lt;script setup&gt;
import { addClass, eleStyleValue } from "fok-js";
import { ref, onMounted } from 'vue';

const myH2 = ref();
onMounted(() =&gt; {
  console.log(eleStyleValue(myH2.value, "color"));
  //rgba(0, 0, 0, 0.85)
  addClass(myH2.value, "my-h2");
  console.log(eleStyleValue(myH2.value, "color"));
  //rgb(255, 0, 0)
  console.log(eleStyleValue(myH2.value, "font-size"));
  //21px
});
&lt;/script&gt;
&lt;style lang="scss" scoped&gt;
 .my-h2 {
   color: red;
 }
&lt;/style&gt;</code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_颜色值操作">颜色值操作</h3>
<div class="sect3">
<h4 id="_rgbtohex_将rgb颜色值转换为十六进制颜色值">rgbToHex 将RGB颜色值转换为十六进制颜色值</h4>
<div class="paragraph">
<p>r, g, 和 b 需要在 [0, 255] 范围内。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { rgbToHex } from "fok-js";

console.log(rgbToHex(255, 0, 0));
//#ff0000
console.log(rgbToHex(123, 123, 123));
//#7b7b7b</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_hextorgb_将十六进制颜色值转换为rgb颜色值">hexToRGB 将十六进制颜色值转换为RGB颜色值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { hexToRGB } from "fok-js";

console.log(hexToRGB("#1a2b3c"));
//rgb(26, 43, 60)
console.log(hexToRGB("000000"));
//rgb(0, 0, 0)</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_randomcolor_随机生成颜色">randomColor 随机生成颜色</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { randomColor } from "fok-js";

console.log(randomColor());
//#ef4923
console.log(randomColor());
//#97d1a5</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_bom">bom</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_parsequerystring_url参数转对象">parseQueryString url参数转对象</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { parseQueryString } from 'fok-utils';

console.log(parseQueryString('www.baidu.com?aaa=123&amp;bbb=sfd'));
// {aaa: "123", bbb: "sfd"}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_stringfyquerystring_对象序列化">stringfyQueryString 对象序列化</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { stringfyQueryString } from 'fok-utils';

let obj = {aaa: "123", bbb: "sfd"};
console.log(stringfyQueryString(obj));
// aaa=123&amp;bbb=sfd</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getexplore_获取浏览器类型和版本">getExplore 获取浏览器类型和版本</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getExplore } from "fok-utils";

console.log(getExplore());
//Chrome: 120.0.0.0</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getos_获取操作系统类型">getOS 获取操作系统类型</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getOS } from "fok-utils";

console.log(getOS());
//windows</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getkeyname_根据keycode获得键名">getKeyName 根据keycode获得键名</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getKeyName } from "fok-utils";

console.log(getKeyName(20));
//Caps Lock
console.log(getKeyName(78));
//N
console.log(getKeyName(200));
//Unknow Key(Key Code:200)</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_issupportwebp_判断浏览器是否支持webp格式图片">isSupportWebP 判断浏览器是否支持webP格式图片</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { isSupportWebP } from "fok-utils";

console.log(isSupportWebP());
//true</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_dom">dom</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_getscrolltop_获取滚动条距顶部的距离">getScrollTop 获取滚动条距顶部的距离</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getScrollTop } from 'fok-utils';

console.log(getScrollTop());
// 0</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_offset_获取一个元素的距离文档document的位置">offset 获取一个元素的距离文档(document)的位置</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;div&gt;
    &lt;h2 ref="myH2"&gt;登录&lt;/h2&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script setup&gt;
  import { offset } from 'fok-utils';
  import { ref, onMounted } from 'vue';

  const myH2 = ref(null);
  onMounted(() =&gt; {
    console.log(offset(myH2.value));
    //{left: 0, top: 0}
  });
&lt;/script&gt;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_scrollto_在duration时间内滚动条滚动到to指定位置">scrollTo 在${duration}时间内，滚动条滚动到${to}指定位置</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;div style="height: 1500px; width: 100%;"&gt;&lt;/div&gt;
&lt;/template&gt;

&lt;script setup&gt;
  import { scrollTo } from 'fok-utils';

  scrollTo(1000, 2000);
&lt;/script&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>效果为在2秒时间内，垂直滚动条平滑滚动到1000位置。</p>
</div>
</div>
<div class="sect2">
<h3 id="_setscrolltop_设置滚动条距顶部的距离">setScrollTop 设置滚动条距顶部的距离</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;div style="height: 1500px; width: 100%;"&gt;&lt;/div&gt;
&lt;/template&gt;

&lt;script setup&gt;
  import { scrollTo } from 'fok-utils';
  import { onMounted } from 'vue';

  onMounted(() =&gt; {
    setScrollTop(200);
  });
&lt;/script&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>效果为垂直滚动条直接定位到200位置。</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_数学">数学</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_randomnum_生成指定范围的随机整数">randomNum 生成指定范围的随机整数</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { randomNum } from "fok-utils";

console.log(randomNum(1, 2));
//1
console.log(randomNum(50, 100));
//96
console.log(randomNum(100, 50));
73</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_randomstr_生成指定位数的随机字符串">randomStr 生成指定位数的随机字符串</h3>
<div class="paragraph">
<p>生成的字符串包含英文字母的大小写以及数字。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { randomStr } from "fok-utils";

console.log(randomStr(8));
//2siYhXfG
console.log(randomStr(5));
//YfK4N</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_硬件操作">硬件操作</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_print_打印">print 打印</h3>
<div class="paragraph">
<p>局部打印。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vue" data-lang="vue">&lt;template&gt;
  &lt;div ref="printArea" &gt;
	//需要打印的内容
  &lt;/div&gt;
  &lt;f-button @click="myClick"&gt;打印&lt;/f-button&gt;
&lt;/template&gt;

&lt;script setup&gt;
import { ref } from 'vue';
import { FButton } from 'fok-ui';
import { print } from 'fok-js';

const printArea = ref(); //需要打印的HTML页面
const printConfig = { //打印配置，支持扩展
	isPreview: true //是否预览
}

const myClick = () =&gt; {
	print(printArea.value, printConfig); //打印
}
&lt;/script&gt;</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 10. 打印参数</caption>
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
<th class="tableblock halign-left valign-top">是否必传</th>
<th class="tableblock halign-left valign-top">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">printArea</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HTML</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">需要打印的HTML页面</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">printConfig</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Object</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">打印配置</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all fit-content">
<caption class="title">Table 11. printConfig配置项</caption>
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名称</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">说明</th>
<th class="tableblock halign-left valign-top">是否必传</th>
<th class="tableblock halign-left valign-top">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">isPreview</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是否预览</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_服务">服务</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_storage_缓存">storage 缓存</h3>
<div class="paragraph">
<p>全局缓存，包含localstorage和sessionstorage。</p>
</div>
<div class="sect3">
<h4 id="_getlocal_获取localstorage值">getLocal 获取localstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.getLocal('his_menu_open_url')</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_setlocal_设置localstorage值">setLocal 设置localstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.setLocal('his_menu_open_url', 'xxx');</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_getsession_获取sessionstorage值">getSession 获取sessionstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.getSession('his_menu_nav');</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_setsession_设置sessionstorage值">setSession 设置sessionstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.setSession('his_menu_nav', 'xxx');</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_removelocal_删除localstorage值">removeLocal 删除localstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.removeLocal('his_menu_open_url');</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_removesession_删除sessionstorage值">removeSession 删除sessionstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.removeSession('his_menu_nav');</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_clearlocal_删除全部localstorage值">clearLocal 删除全部localstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.clearLocal();</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_clearsession_删除全部sessionstorage值">clearSession 删除全部sessionstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.clearSession();</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_clearall_删除全部localstorage和sessionstorage值">clearAll 删除全部localstorage和sessionstorage值</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { Storage } from 'fok-js';

Storage.clearAll();</code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_cookie">cookie</h3>
<div class="sect3">
<h4 id="_getcookie_根据name读取cookie">getCookie 根据name读取cookie</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getCookie } from 'fok-js';

console.log(getCookie("myCookie"));
// ' '</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_setcookie_设置cookie">setCookie 设置Cookie</h4>
<div class="paragraph">
<p>参数分别为name、value和days（过期时间）。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getCookie, setCookie } from 'fok-js';

setCookie('myCookie', '13sdf', 10);
console.log(getCookie("myCookie"));
// '13sdf'</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_removecookie_根据name删除cookie">removeCookie 根据name删除cookie</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import { getCookie, setCookie, removeCookie } from 'fok-js';

removeCookie('myCookie');
console.log(getCookie("myCookie"));
// ' '
setCookie('myCookie', '13sdf', 10);
console.log(getCookie("myCookie"));
// '13sdf'
removeCookie('myCookie');
// ' '</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2025-10-15 15:59:25 +0800
</div>
</div>
</body>
</html>